﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;

namespace SystemModule
{
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
    public class TClientMagic //Size 84
    {
        public char Key;
        public byte Level;
        public int CurTrain;
        public TMagic Def;

        public byte[] ToByte()
        {
            using (var memoryStream = new MemoryStream())
            {
                var backingStream = new BinaryWriter(memoryStream);
                backingStream.Write(Key);
                backingStream.Write(Level);
                backingStream.Write(CurTrain);

                backingStream.Write((byte)0);
                backingStream.Write((byte)0);

                backingStream.Write(Def.ToByte());

                var stream = backingStream.BaseStream as MemoryStream;
                return stream.ToArray();
            }
        }
    }
}
